import { BrowserRouter as Router,Route,Switch,Redirect } from 'react-router-dom'
import Layout from '@/pages/Layout'
import Login from './pages/Login'
import 'antd/dist/antd.css'
// 在ant下面导入自己的样式，防止样式覆盖
import '@/index.scss'
import { isAuth } from './utils'
import { message } from 'antd'
import PrivateRoute from './components/PrivateRouter'
export default function App(){
  return (
    <div>
      <Router>
        <div>
          <Switch>
            {/* 写死了规则 */}
            {/* <Redirect to='/home'/> */}
            {/* 下面的扩展性更好，可以写一下简单逻辑，例如导航守卫 */}
            <Route path='/' exact render={()=>{
              return ( 
                <Redirect to='/home'/>
              )
            }}>
              

              

            </Route>
            <Route path='/login' component={Login}></Route>
            <PrivateRoute >
              <Layout/>
            </PrivateRoute>
          {/* <Route path='/home' render={()=>{
            if(isAuth()){
              return <Layout/>
            }else{
              message.error('请先登陆')
              return <Redirect to='/login'></Redirect>
            }
          }}></Route> */}
          </Switch>
        </div>
      </Router>
    </div>
  )
}